#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
using namespace std;
int b[1000];
int main()
{
    string a;
    int n, ans = 0;
    cin >> n;
    while (n--)
    {
        cin >> a;
        ans = 0;
        memset(b, 0, sizeof(b));
        if (a.size() < 2)
        {
            cout << 0 << endl;
            continue;
        }
        for (int i = 0; i < a.size(); i++)
        {
            b[a[i]]++;
            if (b[a[i]] <= 2)
            {
                ans++;
            }
        }
        cout << ans / 2 << endl;
    }
    return 0;
}